<?php
	require_once "db_connection.php";
	error_reporting(E_ALL ^ E_NOTICE);
	$limit = 15;
	
	$query ="SELECT
			  COUNT(*) as num
			  FROM
			  affiliate";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages['num'];
	
	$stages = 3;
	$page = mysql_real_escape_string($_GET['idx']);
	//$page = $_GET['idx'];
	if($page){
		$start = ($page - 1) * $limit; 
	}else{
		$start = 0;	
		}
	
	$sql = mysql_query("SELECT
					city.cityid,
					city.cityname,
					country.countryname,
					country.countrycode
					FROM
					city
					INNER JOIN country ON country.countryid = city.countryid ORDER BY country.countryname, city.cityname
					LIMIT $start, $limit");	
						
	$acc_num = $start;
	$class_alternate = "";
	while($row = mysql_fetch_array($sql, MYSQL_ASSOC))
	{
		$acc_num=$acc_num+1;
		echo"<tr class='". $class_alternate ."'>
						<td>".$acc_num."</td>
						<td><b>" .$row['cityname']. "</b></td>
						<td>" .$row['countryname']. "</td>
						<td>" .$row['countrycode']. "</td>
						<td class='options-width'>
						<a href='cities_edit.php?id=".$row['cityid']."' title='Edit' class='icon-1 info-tooltip'></a>
						<a href='#' title='Delete' class='icon-2 info-tooltip' onclick='deleteCities(\"".$row["cityid"]."\");return false;'></a>
						<a href='cities_view.php?id=".$row['cityid']."' title='View' class='icon-5 info-tooltip'></a>
						</td>
					</tr> ";
		if($class_alternate==""){ $class_alternate="alternate-row";}
		else{$class_alternate="";}				
	}
?>
